package com.project.springboot.singleton;

/**
 * description: 使用静态内部类实现单例模式
 * @author 朱正磊
 * @date 2021-03-03 16:02:00
 */
public class Singleton4 {

    private static class SingletonHolder {
        // 静态初始化器，由JVM来保证线程安全
        private static Singleton4 instance = new Singleton4();
    }

    private Singleton4() {

    }

    public static Singleton4 newInstance() {
        return SingletonHolder.instance;
    }

}
